import Taro from '@tarojs/taro'
import {
  CART_INFO, CART_SAVE, CART_UPDATE, CART_DELETE, CART_SELECT_ALL
} from '@constants/cart'

const INITIAL_STATE = {
  cartInfo: {}
}

export default function cart(state = INITIAL_STATE, action) {
  switch(action.type) {
    case CART_INFO: {
      return {
        ...state,
        cartInfo: action.payload
      }
    }
    case CART_SAVE:
    case CART_UPDATE:
    case CART_DELETE:
    case CART_SELECT_ALL: {
      return { ...state }
    }
    default:
      return state
  }
}
